using UnityEngine;
using System.Collections.Generic;

public class ItemManager : MonoBehaviour {
	
	//The mental object manager
	public MentalObjectManager objManager;
	
	//The synth - to be passed on to instantiated objects
	public Synth synth;
	
	//prefab item - sphere
	public ItemScript item;
	private const float OFFSET = 100;//ensures the item won't be instantiated off-screen
	private const float MAX_HEIGHT = 567;//the arbitrary barrier at the top of reachable area
	
	//the active items in the world
	HashSet<ItemScript> activeItems;
	
	// Use this for initialization
	void Start () {
		activeItems = new HashSet<ItemScript>();
		addItem();
	}
	
	void addItem() {
		ItemScript newItem = (ItemScript)Instantiate(item, getSpawnLocation(),transform.rotation);
		newItem.synth = synth;
		activeItems.Add (newItem);
		objManager.addItem(newItem);
	}
	
	Vector3 getSpawnLocation() {
		float newX = UnityEngine.Random.Range(OFFSET, Screen.width-OFFSET);
		float newY = UnityEngine.Random.Range(OFFSET, MAX_HEIGHT);
		return new Vector3(newX, newY, 0);//because we don't care about z!
	}
	
	// Update is called once per frame
	void Update () {
		
		//add objects
	}
}
